<?php

namespace PhpYes\Modules\Log;


class LogRecord extends LogRecordBase
{
    /**
     * @param string $level - refer LogLevel
     * @param string $message
     * @return void
     */
    public function log($level, $message)
    {
        $this->level = $level;
        $this->message = $message;
    }

    /**
     * get 最终日志内容
     * @return string
     */
    public function getLogMessage()
    {
        $dt = $this->dt ? $this->dt : new \DateTime();
        $level = $this->level ? $this->level : LogLevel::ERROR;
        $msg = $this->message ? $this->message : 'empty';

        return $dt->format('Y-m-d H:i:s') . "\t" . $level . "\t" . str_replace(array("\r\n", "\r", "\n"), ' ', $msg);
    }
}